package pascale;

import java.util.Scanner;


public class Class03 {

	/**
	 * @param args
	 */
	
	public static double addition(double num1, double num2)
	{
		return num1 + num2;
	}
	
	public static double soustraction(double num1, double num2)
	{
		return num1 - num2;
	}
	
	public static double multiplication(double num1, double num2)
	{
		return num1 * num2;
	}
	
	public static double division(double num1, double num2)
	{
		if (num2 == 0)
		{
			System.out.println("Division by 0 !");
			return 0;
		}
		else
			return num1 / num2;
	}
	
	public static void main(String[] args) {
		// TODO Auto-generated method stub

		// exe 1 : print numbers from 1 to 100
		System.out.println("Exe 1 : print numbers from 1 to 100 \n");
		for(int i = 1 ; i <= 100; i++)
		{
			System.out.println(i + " ");
		}
		
		// exe 2 : find whether the number is odd or even
		System.out.println("\nExe 2 : find whether the number is odd or even\n");
		System.out.println("Enter an integer to check if it is odd or even :");
	    Scanner in = new Scanner(System.in);
	    int x = in.nextInt();
	      
		if ( x % 2 == 0 )
	         System.out.println(x + " is an even number.");
	      else
	         System.out.println(x + " is an odd number.");
		
		// exe 3 : search a given number from an integer array
		System.out.println("\nExe 3 : search a given number from an integer array\n");
		System.out.println("Enter an integer :");
		int nb = in.nextInt();
		int nbArray[] = {1,2,3,4,5,6,7,8,9,10};
		System.out.println("The number is " + nbArray[nb-1]);
		
		// exe 4 : samples on primitive types (and rounding operations)
		System.out.println("\nExe 4 : samples on primitive types (and rounding operations)\n");
	    double d = 100.675;
        float g = 90f;

		System.out.println(d + " round : " + Math.round(d));   
        System.out.println(g + " round : " + Math.round(g)); 
		
        // exe 5 calculator
        System.out.println("\nExe 5 : Calculator\n");
        in = new Scanner(System.in);
        System.out.println("Write a number : ");
	    double y = in.nextDouble();
	    System.out.println("Write a number : ");
	    double z = in.nextDouble();
	    
	    // display
	    System.out.println("The addition of " + y + " and " + z + " = " + addition(y,z));
	    System.out.println("The soustraction of " + y + " and " + z + " = " + soustraction(y,z));
	    System.out.println("The multiplication of " + y + " and " + z + " = " + multiplication(y,z));
	    System.out.println("The division of " + y + " and " + z + " = " + division(y,z));
	    
	    
	}

}
